<?php

namespace App\Admin\Http\Controllers\Gift;

use Flash;
use App\Admin\Eloquent\GiftReceive;
use App\Admin\Eloquent\GiftActivity;
use App\Admin\Eloquent\User;
use App\Admin\Http\Controllers\Controller;
use App\Extensions\Pagination\BootstrapThreePresenter;
use \Illuminate\Http\Request;
use App\Exceptions\BusinessException;

class RecordController extends Controller
{
	/**
	 * 查看红包领取记录
	 * @param  [type] $id [description]
	 */
	public function index($id,Request $request){
		$query=$request->all();
		$query['activity_id']=$id;
		//红包活动
		$activity=GiftActivity::findOrFail($id);

		//分页查询
		$list=GiftReceive::paging_query($query);
		$list->appends($query);
		$links = (new BootstrapThreePresenter($list))->render();

		return view('admin.gift.record.index', compact('list', 'links', 'query','activity'));
	}

	/**
	 * 查看记录详细
	 * @param  [type] $id 红包活动编号
	 * @return [type]     [description]
	 */
	public function show($activity,$id){
		$info=GiftReceive::findOrFail($id);
		$info->username=User::where('id','=',$info->user_id)->value('username');
		$activity=GiftActivity::findOrFail($info->activity_id);

		return view('admin.gift.record.show', compact('info','activity'));
	}
}